
; CC8E Version 1.3D, Copyright (c) B Knudsen Data
; C compiler for the PIC18 microcontrollers
; ************  25. Oct 2011  15:16  *************

	processor  PIC18F4520
	radix  DEC

Zero_       EQU   2
TRISC       EQU   0xF94
TRISB       EQU   0xF93
TRISA       EQU   0xF92
PORTC       EQU   0xF82
PORTB       EQU   0xF81
PORTA       EQU   0xF80
belt        EQU   0x00
sit         EQU   0x02

	GOTO main

  ; FILE Bilbeltealarm.c
			;
			;
			;void main ()
			;{
main
			;	TRISC=0x00;
	CLRF  TRISC,0
			;	TRISB.0=1;
	BSF   TRISB,0,0
			;	TRISA.4=1;
	BSF   TRISA,4,0
			;	uns16 belt = 0;	//belt is straped or not
	CLRF  belt,0
	CLRF  belt+1,0
			;	uns16 sit = 0;	//someone sitting in the siet or not
	CLRF  sit,0
	CLRF  sit+1,0
			;	
			;	
			;	while (1)				//while runing
			;	{
			;		belt = 0;			//sets beelt and sit to 0
m001	CLRF  belt,0
	CLRF  belt+1,0
			;		sit = 0;
	CLRF  sit,0
	CLRF  sit+1,0
			;		
			;		if (!PORTA.4)	//someone straps belt on
	BTFSC PORTA,4,0
	BRA   m002
			;		{		
			;			belt=1;
	MOVLW 1
	MOVWF belt,0
	CLRF  belt+1,0
			;		}	
			;
			;		if(!PORTB.0)			//some one sits down
m002	BTFSC PORTB,0,0
	BRA   m003
			;		{
			;			sit=1;
	MOVLW 1
	MOVWF sit,0
	CLRF  sit+1,0
			;		}
			;		if(sit && !belt)		//is someone sitting whitout the belt on
m003	MOVF  sit,W,0
	IORWF sit+1,W,0
	BTFSC 0xFD8,Zero_,0
	BRA   m004
	MOVF  belt,W,0
	IORWF belt+1,W,0
	BTFSS 0xFD8,Zero_,0
	BRA   m004
			;		{
			;			PORTC.2 = 1;
	BSF   PORTC,2,0
			;		}
			;		else
	BRA   m001
			;		{
			;			PORTC.2 = 0;
m004	BCF   PORTC,2,0
			;		}
			;	}
	BRA   m001

	END


; *** KEY INFO ***

; 0x000004   33 word(s)  0 % : main

; RAM usage: 4 bytes (4 local), 1532 bytes free
; Maximum call level: 0
; Total of 35 code words (0 %)
